package com.usermanage.util;


import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 過客 on 2018/5/16
 */
@Slf4j
public class FileUtil {
    //日志信息处理，记录系统异常及重要日志
    public static void writeLinesByLog(String fileContent) {
        try {
            String nowtime = DateUtil.getNowTimeString();
            fileContent = nowtime + "\r\n" + fileContent + "\r\n-----------------------------------------------------------------";
            String fileName = "C:\\EOSlog\\log_" + DateUtil.getNowDayString() + ".txt";//不同系统用不同的文件夹名
            File file = new File(fileName);
            List<String> lines = new ArrayList<String>();
            lines.add(fileContent);
            FileUtils.writeLines(file, "UTF-8", lines, true);
        } catch (Exception ex) {
            log.error("发生异常>>> " + ex.toString());
        }
    }
}
